package cn.com.headfree.filter;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

/**
 * @description:日志拦截器，进行过滤登陆与菜单日志
 * @Author: panl
 * @Date: 2020/3/12 12:40
 */
public class RecordLogFilter extends Filter<ILoggingEvent> {
    @Override
    public FilterReply decide(ILoggingEvent event) {

        if (!event.getLoggerName().equals("cn.com.headfree.base.common.MenuLog")&&!event.getLoggerName().equals("cn.com.headfree.base.common.UserLog")) {
            return FilterReply.DENY;
        } else{
            return FilterReply.ACCEPT;
        }
    }

    public String getPackName(String className){
        String packName = className.substring(0,className.lastIndexOf("."));
        return packName;
    }
}
